package cn.sunjinxin.trade.adapter.adapter.pay;

import cn.sunjinxin.savior.event.context.EventContext;
import cn.sunjinxin.savior.event.control.Eventer;
import cn.sunjinxin.trade.domain.even.TradeEvent;
import cn.sunjinxin.trade.domain.model.Order;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author issavior
 */
@RestController("/trade")
public class PayNotifyAdapter {

    @RequestMapping("/pay")
    public void notify(Map<String, String> params) {
        // 发布用户支付成功事件
        Eventer.SYNC.publish(EventContext.<TradeEvent, Order>builder()
                .eventId(String.valueOf(1L))
                .eventType(TradeEvent.PAY_RESULT)
                .request(null)
                .build());
        System.out.println("支付宝支付回调");
    }
}
